#pragma once

#include <AVUIDispatcherObject.h>
#include <AVUIDispatcher.h>

namespace AVUI {

class LoadedOrUnloadedOperation : public Object
{
public:
    LoadedOrUnloadedOperation(DispatcherOperationCallback* pCallback, DependencyObject* pTarget) : m_pCallback(pCallback), m_pTarget(pTarget), m_cancelled(false) { }
    void Cancel() { m_cancelled = true; }
    void DoWork() { if(!m_cancelled) m_pCallback->Invoke(m_pTarget, NULL); }

private:
    TRefCountedPtr<DispatcherOperationCallback> m_pCallback;
    bool m_cancelled;
    TRefCountedPtr<DependencyObject> m_pTarget;
};

             
class MediaContext : public DispatcherObject
{
public:
    static MediaContext* From(Dispatcher* pDispatcher) { static MediaContext mediaContext; return &mediaContext; }
    TRefCountedPtr<LoadedOrUnloadedOperation> AddLoadedOrUnloadedCallback(DispatcherOperationCallback* pCallback, DependencyObject* pTarget) { return object_allocate<LoadedOrUnloadedOperation>(pCallback, pTarget); };
    void RemoveLoadedOrUnloadedCallback(LoadedOrUnloadedOperation* pOp) { };
    void VerifyWriteAccess() { }
    void BeginInvokeOnRender(DispatcherOperationCallback* pCallback, Object* pArg);
};

class MediaSystem
{
public:
    static void AssertSameContext(DependencyObject*, DependencyObject*) { }
};


}; // namespace AVUI


